<!DOCTYPE html>
<title>Tests that custom events with unprefixed animations names are correctly dispatched.</title>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script>
var animationStartReceived = false;
var animationIterationReceived = false;

document.addEventListener('animationstart', () => {
  animationStartReceived = true;
});

document.addEventListener('animationiteration', () => {
  animationIterationReceived = true;
});

async_test(t => {
  document.addEventListener('webkitAnimationStart', t.unreached_func('webkitAnimationStart event listener should not have been called'));
  document.addEventListener('webkitAnimationIteration', t.unreached_func('webkitAnimationIteration event listener should not have been called'));
  document.addEventListener('webkitAnimationEnd', t.unreached_func('webkitAnimationEnd event listener should not have been called'));

  document.addEventListener('animationend', t.step_func_done(() => {
    assert_true(animationStartReceived);
    assert_true(animationIterationReceived);
  }));

  var custom = document.createEvent('CustomEvent');
  custom.initCustomEvent('animationstart', true, true, null);
  document.dispatchEvent(custom);
  custom = document.createEvent('CustomEvent');
  custom.initCustomEvent('animationiteration', true, true, null);
  document.dispatchEvent(custom);
  custom = document.createEvent('CustomEvent');
  custom.initCustomEvent('animationend', true, true, null);
  document.dispatchEvent(custom);
}, "Tests that custom events with unprefixed animations names are correctly dispatched");
</script>
